Don't divide by zero when computing speed. (this means you, saved Garmin
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 30 Apr 2006 03:26:48 +0000 (03:26 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 30 Apr 2006 03:26:48 +0000 (03:26 +0000)
tracks...)

gpsbabel/route.c

index df156b0a9224c9fe601c203330b2caf57e58ccbe..e34130244ce751374c2488ea688874e458d79c94 100644 (file)
@@ -1,5 +1,5 @@
 /* 
-    Copyright (C) 2002 Robert Lipe, robertlipe@usa.net
+    Copyright (C) 2002-2006 Robert Lipe, robertlipe@usa.net
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -460,8 +460,11 @@ void track_recompute(const route_head *trk)
        first.creation_time = 0;
 
        QUEUE_FOR_EACH((queue *)&trk->waypoint_list, elem, tmp) {
+               time_t timed;
                double tlat, tlon, plat, plon, dist;
+
                this = (waypoint *)elem;
+               timed = this->creation_time - prev->creation_time;
                /* gcdist and headin want radians, not degrees */
                tlat = RAD(this->latitude);
                tlon = RAD(this->longitude);
@@ -470,8 +473,9 @@ void track_recompute(const route_head *trk)
                this->course = DEG(heading(plat, plon,
                        tlat, tlon));
                dist = radtometers(gcdist(plat, plon, tlat, tlon));
-               this->speed = dist / 
-                       labs(this->creation_time - prev->creation_time);
+               if (timed) {
+                       this->speed = dist / labs(timed);
+               }
 
                prev = this;
        }